package main;
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import screens.Demo;
import screens.HaveWeMetBefore;
import screens.Lesson1;
import screens.Lesson2;
import screens.Lesson3;
import screens.Lesson4;
import screens.SensorSelection;
import screens.TouchMe;


/**
 * This class implements a simple graphical user interface
 */

public class UserInterface extends JFrame implements ActionListener, KeyEventDispatcher {

	private static JFrame frame;
	
	// screensobot
	public static TouchMe touchMe;
	public static SimulatorPanel simulatorPanel;
	public static SensorSelection sensorSelection;
	public static HaveWeMetBefore haveWeMetBefore;
	public static Demo demo;
	public static Lesson1 lesson1;
	public static Lesson2 lesson2;
	public static Lesson3 lesson3;
	public static Lesson4 lesson4;
	
    // Construct a UserInterface
    public UserInterface() {
    	this.setFocusable(true);
    	this.setVisible(true);
    	KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    	manager.addKeyEventDispatcher(this);

    	// initialising the window
    	
        frame = new JFrame("HCI Practical 2010");
        frame.setSize(800, 600);
        frame.setResizable(false);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
        
        // initialising the screens
        
        touchMe = new TouchMe();
        simulatorPanel = new SimulatorPanel();
        sensorSelection = new SensorSelection();
        haveWeMetBefore = new HaveWeMetBefore();
        demo = new Demo();
        lesson1 = new Lesson1();
        lesson2 = new Lesson2();
        lesson3 = new Lesson3();
        lesson4 = new Lesson4();
        
        setContentPane(touchMe);
    }
    
    public static void setContentPane(JPanel newContentPane) {
    	frame.setContentPane(newContentPane);
    	frame.pack();
    }

    /**
     *  Actions to be performed on clicking buttons
     */
    public void actionPerformed(ActionEvent event) {

    }

    // Main method to create GUI
	public static void main(String[] args) {
		UserInterface gui = new UserInterface();
	}

	@Override
	public boolean dispatchKeyEvent(KeyEvent arg0) {
		if (arg0.getID() == KeyEvent.KEY_RELEASED) {
			simulatorPanel.keyReleased(arg0);
		}
		return false;
	}

}
